<?php

namespace ElementVip\Shop\Backend\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Menu;

class BackendServiceProvider extends ServiceProvider
{
    /**
     * This namespace is applied to your controller routes.
     *
     * In addition, it is set as the URL generator's root namespace.
     *
     * @var string
     */
    protected $namespace = 'ElementVip\Shop\Backend\Http\Controllers';

    /**
     * Define your route model bindings, pattern filters, etc.
     *
     * @return void
     */
    public function boot()
    {
        if (!$this->app->routesAreCached()) {
            $this->mapWebRoutes();
        }

        $this->loadViewsFrom(__DIR__ . '/../../resources/views', 'shop-backend');

        $this->loadMigrationsFrom(__DIR__ . '/../../migrations');

	    //添加配置文件
	    $this->publishes([
		    __DIR__ . '/../../config/city.php' => config_path('city.php'),
	    ], 'shop-city-config');

	    $this->publishes([
		    __DIR__ . '/../../template/template.xlsx' => public_path('assets/template').'/store_import_template.xlsx'
	    ], 'store-import-template');

        $this->registerMenu();
    }


    public function register()
    {

    }

    /**
     * Define the "web" routes for the application.
     *
     * These routes all receive session state, CSRF protection, etc.
     *
     * @return void
     */
    protected function mapWebRoutes()
    {
        Route::group([
            'middleware' => ['web', 'auth.admin:admin'],
            'namespace' => $this->namespace,
        ], function ($router) {
            require __DIR__ . '/../Http/routes.php';
        });
    }

    private function registerMenu()
    {
        Menu::make('topMenu', function ($menu) {

            $menu->add('<i class="iconfont icon-mendianguanli"></i>
                            <span>门店管理</span>', 'admin/shop/list/store')->active('admin/shop/*');

        });
    }
//    protected function  registerMigrations()
//    {
//        return $this->loadMigrationsFrom(__DIR__ . '/../../migrations');
//    }
}
